<style>
    .xxpayPopupDiv .layui-form-label {
        width:120px !important;
        margin-left:1%;
    }
    .xxpayPopupDiv .layui-input-inline {
        width: 80% !important;
    }
</style>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-tab layui-tab-brief">
            <div class="layui-tab-content">
                <form class="layui-form center">
                    <input type="hidden" id="id" name="id"/>
                    <div class="layui-form-item">
                        <label class="layui-form-label">用户类型</label>
                        <div class="layui-input-inline">
                            <input style="color:#D2D2D2" type="text" id="infoType" readonly class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">系统用户ID</label>
                        <div class="layui-input-inline">
                            <input style="color:#D2D2D2" type="text" id="infoId" readonly class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">支付渠道接口类型</label>
                        <div class="layui-input-inline" >
                            <input style="color:#D2D2D2" type="text" id="ifTypeCode" readonly class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">渠道商户号</label>
                        <div class="layui-input-inline" >
                            <input type="text" name="channelMchId" id="channelMchId" placeholder="渠道商户号" required lay-verify="required"  autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">备注</label>
                        <div class="layui-input-inline" >
                            <input type="text" name="remark" id="remark" placeholder="备注" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <button type="button" class="layui-hide xxpayYesBtn" lay-submit="" lay-filter="update">确认</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    
    layui.use(['form','table','util','admin'],function(){
        var form = layui.form
        , $ = layui.$
        , admin = layui.admin
        , layer = layui.layer 
        , element = layui.element
        , view = layui.view
        , table = layui.table;
        
        element.render('breadcrumb', 'breadcrumb'); //渲染导航信息
        
        var id = view.getOpenParams('id');
        $('#id').val(id);
        admin.req({
            type: 'post',
            url: layui.setter.baseUrl + '/config/division/mch/get',
            data: { id: id},
            error: function(err){layer.alert(err);},
            success: function(res){
                if(res.code == 0){
                    $('#infoId').val(res.data.infoId);
                    $('#infoType').val(res.data.infoType =='1' ? '代理商' : '商户');
                    $('#channelMchId').val(res.data.channelMchId);
                    $('#remark').val(res.data.remark);

                    // 加载支接口类型
                    admin.req({
                        type: 'post',
                        url: layui.setter.baseUrl + '/config/pay_interface_type/get?ifTypeCode='+res.data.ifTypeCode,
                        async: false,
                        error: function(err){
                            layer.alert(err);
                        },
                        success: function(ifRes){
                            $('#ifTypeCode').val("[" + res.data.ifTypeCode + "]" + ifRes.data.ifTypeName);
                        }
                    });

                    form.render();
                }
            }
        });

        form.on('submit(update)', function(data){
            admin.req({
                type: 'post',
                url: layui.setter.baseUrl + '/config/division/mch/update', //模拟接口,
                data: data.field,
                error: function(err){layer.alert(err.msg,{title:"请求失败"})},
                success: function(res){
                    if(res.code == 0){
                        layer.alert(res.msg, {title: '保存成功'},function(index){
                            layer.closeAll(); //关闭所有弹层
                            layui.table.reload('tableReload'); //调用业务弹层外表格重新加载
                        });
                    }
                }
            });
            return false;
        });

    });
    
</script>
